//
//  MoreDoctorList.m
//  EcmDoctor
//
//  Created by Mac on 16/2/22.
//  Copyright © 2016年 张进. All rights reserved.
//

#import "MoreDoctorList.h"
#import "NetWorkUtil.h"
#import <SSKeychain/SSKeychain.h>
#import "AppUtils.h"
@implementation MoreDoctorList
+(void)getMoreDoctorWith:(NSString *)str success:(void (^)(NSMutableArray *))success failure:(void (^)(NSError *))failure
{
    
    NetWorkBaseRequest *req = [[NetWorkBaseRequest alloc] init];
    //请求参数
    
    req.moduleName = @"UserRS";

    req.methodName = @"getDoctorAllList";
    [req setValue:@"" forKey:@"type"];
    [req setValue:@"" forKey:@"typeId"];
     [req setValue:@"" forKey:@"where"];
    
    [NetWorkUtil requestWithPOST:req success:^(NetWorkBaseResponse *responseObject) {
        NSError *error = nil;
        
        NSLog(@"------------%@",responseObject);
        if (responseObject.code.integerValue == 1) {
            if (!responseObject.data) {
                success(nil);
                return;
            }
            
            NSData *data = [responseObject.data dataUsingEncoding:NSUTF8StringEncoding];
            NSArray *userAttrs = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
            NSLog(@"---------%@",userAttrs);
            if (error) {
                failure(error);
                return;
            }
            NSMutableArray *doctorListAry=[NSMutableArray array];
            for(int i=0;i<userAttrs.count;i++)
            {
                  MoreDoctorList *doctorList = [[MoreDoctorList alloc]initWithDictionary:userAttrs[i]];
                [doctorListAry addObject:doctorList];
            }
          
            success(doctorListAry);
            
        } else{
            error = [NSError errorWithDomain:responseObject.msg code:responseObject.code.integerValue userInfo:nil];
            failure(error);
        }
        
    } failure:^(NSError *error) {
        failure(error);
        
    } cache:NO];
    
}
@end
